#!/usr/bin/env python
# -*- coding:utf-8 -*-

import tab_switch
import wx
import calc, output

class tab_switch_2(tab_switch.MainFrame):
    def __init__(self, parent):
        tab_switch.MainFrame.__init__(self, parent)
        self.sk = "N/A"
        self.tt = "N/A"
        self.jc = "N/A"

    def tg_cln( self, event ):
        self.tg_grid.SetCellValue(0, 0, "N/A")
        self.tg_grid.SetCellValue(0, 1, "N/A")
        self.tg_grid.SetCellValue(0, 2, "N/A")
        self.tg_rlt.SetLabelText("计算完成：")

    def tg_output( self, event ):
        op = output.outputer((self.sk,self.jc,self.tt), self.tg_folder.GetPath())
        op.output()

    def bxg_output(self, event):
        op = output
    def tg_calc(self, event):
        gw = float(self.tg_gw.GetValue())
        gh = float(self.tg_gh.GetValue())
        err_msg = "计算完成："
        calc1 = calc.calc1(gw, gh)
        (gw_er, gh_er, self.sk, self.jc, self.tt) = calc1.calc()
        if gw_er > 0:
            err_msg = err_msg + "管道外径输入有误" + "\n"
        elif gh_er > 0:
            err_msg = err_msg + "管道壁厚输入有误" + "\n"
        else:
            err_msg = err_msg + "成功" + "\n"
        self.tg_grid.SetCellValue(0, 0, self.sk)
        self.tg_grid.SetCellValue(0, 1, self.jc)
        self.tg_grid.SetCellValue(0, 2, self.tt)
        self.tg_rlt.SetLabelText(err_msg)


if __name__ == "__main__":
    app = wx.App(False)
    frame = tab_switch_2(None)
    frame.Show(True)
    app.MainLoop()